package cn.iocoder.yudao.module.contract.job;

import cn.hutool.core.date.DateUtil;
import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler;
import cn.iocoder.yudao.module.contract.webservice.ContractWebService;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Date;

@Component
@Slf4j
public class ClientJob implements JobHandler {
    @Resource
    private ContractWebService contractWebService;

    @Override
    public String execute(String param) {
        String endDate = DateUtil.format(new Date(),"yyyyMMdd");
        String vbeln = "";
        if(StringUtils.isNotBlank(param)){
            JSONObject jsonObject = JSONObject.parseObject(param);
            if(jsonObject!=null){
                if(StringUtils.isNotBlank(jsonObject.getString("endDate"))){
                    endDate = jsonObject.getString("endDate");
                }
                if(StringUtils.isNotBlank(jsonObject.getString("vbeln"))){
                    vbeln = jsonObject.getString("vbeln");
                }
            }
        }
        return contractWebService.getClient(endDate,vbeln);
    }
}
